<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
        <div>
            <div id="ligergridDB" class="sq-grid"></div>
        </div>
    </div>

<script type="text/javascript">
	var gridDB = null;
	var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
	$(function () {
		initTab();
		initGridDB();//初始化待办列表
	});
    var ligergridDB;
    
    //初始化待办列表
    function initGridDB(param){
    	ligergridDB = $("#ligergridDB").ligerGrid({
    		url: '<%=path%>/archive/arcReceiptMain/historicalVersionPage.do?id=${id}',
	    	method : 'get',
	        columns: [
				{ display: '交接单名称', 
					render:function (rowdata, rowindex, value){
						return "<span title="+rowdata.listName+">"+rowdata.listName+"</span>";
					}
				},
				{ display: '版本号', name: 'version'},
				{ display: '是否正在使用', name: 'currentVersion',
					render:function (rowdata, rowindex, value){
						return (value == "YES")?"是":"否";
					}
				},
				{
					display:'操作',width:250,
					render:function (rowdata, rowindex, value){
						var h="";
						
			                h+='<a class="sq-button-hasicon" href="javascript:save(';
			                h+="'"+rowdata.id+"',";
			                h+="'view'";
			                h+=")\"><i class='sqBtnIco_4'></i>查看</a>";
			                
			            	h+='<a class="sq-button-hasicon" href="javascript:setHistoricalVersion(';
			                h+="'"+rowdata.id+"',";
			                h+=")\"><i class='sqBtnIco_4'></i>启用当前版本</a>";
						
						return h;
					}
				}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-30,
	        rownumbers:true
	    });
	    gridDB = liger.get("ligergridDB");
	    gridDB.setHeight(100);
	    gridDB.options.isSingleCheck=true;
    }
    
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}
	
	//初始化Tab页
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function(tabid) {
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }
	
  //新增和修改
	function save(id,operate) {
		var title;
		if(operate == "add") {
			title ="新增";
		}else if(operate == "update") {
			title ="修改";
		}else {
			title ="查看";
		}
		Add_navTab("arcReceiptMain"+id+operate, "交接单"+title, '<%=path%>/archive/arcReceiptMain/toSave.do?id='+id+'&operate='+operate , function () {
			grid.reload();
		});
	}
  
  
	function setHistoricalVersion(id) {
		$.ligerDialog.confirm('确定启用当前版本吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'get',
				dataType:'json',
				url: '<%=path%>/archive/arcReceiptMain/setHistoricalVersion.do?id='+id,
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting"});
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 ligergridDB.reload();
						 parent.reloadList();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
	
	/* //页面下方的取消按钮
	 frameElement.dialog.onCancel2 = function () { 
		alert("frameElement.dialog.onCancel ");
		parent.reloadList();
		//frameElement.dialog.close(); 
	}  */
	
</script>

</body>
</html>